using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using HISModels.Entities;

namespace HISModels.Mapping
{
	public class BankMap : EntityTypeConfiguration<Bank>
	{
		public BankMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			this.Property(t => t.NameValue)
				.HasMaxLength(50);
				
			this.Property(t => t.SwiftCode)
				.HasMaxLength(50);
				
			// Table & Column Mappings
			this.ToTable("Banks");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.NameValue).HasColumnName("NameValue");
			this.Property(t => t.SwiftCode).HasColumnName("SwiftCode");
			this.Property(t => t.RecordStatus).HasColumnName("RecordStatus");
			this.Property(t => t.CategoryId).HasColumnName("CategoryId");

			// Relationships
			this.HasOptional(t => t.RefPayerCategory)
				.WithMany(t => t.Banks)
				.HasForeignKey(d => d.CategoryId);
				
		}
	}
}

